home *** CD-ROM | disk | FTP | other *** search
- // Copyright (c)1995 Ray Dream, Inc. All Rights Reserved.
- /* $Id: SandDll.cpp 1.2 1997/07/01 18:19:31 damien Exp $ */
-
- ////////////////////////////////////////////////////////////////////////
- // SandpericShader Example : Sand //
- //--------------------------------------------------------------------//
- // DLL Management //
- ////////////////////////////////////////////////////////////////////////
-
- #ifndef __SandDLL__
- #include "SandDLL.h"
- #endif
-
- #ifndef __COMSand__
- #include "COMSand.h"
- #endif
-
- #ifndef __SandFAC__
- #include "SandFac.h"
- #endif
-
- #ifndef __3DCOFAIL__
- #include "3DCoFail.h"
- #endif
-
- //------------------------------------------------------------------------
- /*
- * DllGetClassObject
- *
- * This function gives a IClassFactory with the appropriate CLSID.
- * This DLL must be in the registration database as a InProcServer
- * for the correct CLSID
- *
- * Parameters:
- * clsID REFCLSID that identifies the class factory
- * desired. Since this parameter is passed this
- * DLL can handle any number of objects simply
- * by returning different class factories here
- * for different CLSIDs.
- *
- * riid REFIID specifying the interface the caller wants
- * on the class object, usually IID_ClassFactory.
- *
- * ppv LPVOID FAR* in which to return the interface
- * pointer.
- *
- * Returns NOERROR on success, otherwise an error code
- */
-
- STDAPI DllGetClassObject(REFCLSID rclsid,
- REFIID riid, LPVOID FAR* ppv) {
- if (!IsEqualCLSID(rclsid, CLSID_Sand))
- return ResultFromScode(E_FAIL);
-
- //Check that we can provide the interface
- if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
- return ResultFromScode(E_NOINTERFACE);
-
- //Return our IClassFactory for the correct objects
- if (IsEqualCLSID(rclsid,CLSID_Sand))
- *ppv=(LPVOID) new SandClassFactory();
-
- if (*ppv == NULL)
- return ResultFromScode(E_OUTOFMEMORY);
-
- //AddRef the object through any interface we return
- ((LPUNKNOWN)*ppv)->AddRef();
-
- return NOERROR;
- }
-
-
- /*
- * DllCanUnloadNow
- *
- * Answers if the DLL can be unload from the memory
- *
- * This function doesn't need any parameter
- *
- * Returns TRUE if nothing is using us, FALSE otherwise.
- */
-
- STDAPI DllCanUnloadNow() {
- SCODE sc;
-
- //Our answer is whether there are any object or locks
- sc=(0L==global_count_Obj && 0L==global_count_Lock) ? S_OK : S_FALSE;
- return ResultFromScode(sc);
- }
-
- //------------------------------------------------------------------------
- //Count number of objects and number of locks.
- long global_count_Obj = 0;
- long global_count_Lock = 0;
-
- STDAPI DllInitRDCom(IShUtilities* shellUtilities) {
- InitCoFailure(shellUtilities);
- sandShellUtilities = shellUtilities;
- return S_OK;
- }
-
-
-